local skel = fk.CreateSkill {
  name = "emo__wuzhuang",
}

Fk:loadTranslationTable{
  ["emo__wuzhuang"] = "武装",
  [":emo__wuzhuang"] = "出牌阶段限两次，你可以弃置一张牌，并判定，若此牌和判定牌点数之和为：小于10，获得一点护甲；10~15，视为使用一张【杀】；大于15，你可令一名角色装备【突击步枪】（若其已有，改为获得2枚子弹）。",

  ["#emo__wuzhuang"] = "武装：弃置1张牌并判定，根据两牌点数和执行效果",
  ["#emo__wuzhuang-choose"] = "武装：一名角色装备【突击步枪】",
}

skel:addEffect("active", {
  anim_type = "offensive",
  prompt = "#emo__wuzhuang",
  card_num = 1,
  card_filter = function (self, player, to_select, selected)
    return #selected == 0 and not player:prohibitDiscard(to_select)
  end,
  target_num = 0,
  can_use = function (self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) < 2
  end,
  times = function (self, player)
    return 2 - player:usedSkillTimes(skel.name, Player.HistoryPhase)
  end,
  on_use = function (self, room, use)
    local player = use.from
    local num = Fk:getCardById(use.cards[1]).number
    room:throwCard(use.cards, skel.name, player, player)
    if player.dead then return end
    local judge = {
      who = player,
      reason = skel.name,
      pattern = ".",
    }
    room:judge(judge)
    if player.dead then return end
    if judge.card then
      num = num + judge.card.number
    end
    if num < 10 then
      room:changeShield(player, 1)
    elseif num > 15 then
      local targets = table.filter(room.alive_players, function (p) return #p:getAvailableEquipSlots(Card.SubtypeWeapon) > 0 end)
      if #targets == 0 then return end
      local to = room:askToChoosePlayers(player, {
        min_num = 1, max_num = 1, cancelable = true, skill_name = skel.name, targets = targets,
        prompt = "#emo__wuzhuang-choose",
      })[1]
      if to == nil then return end
      if table.find(to:getCardIds("e"), function(id) return Fk:getCardById(id).name == "assault_rifle" end) then
        room:addPlayerMark(to, "@ARbullet", 2)
      else
        local weapon = room:printCard("assault_rifle", Card.Spade, 13)
        room:moveCardIntoEquip(to, weapon.id, skel.name, true, player)
      end
    else
      room:askToUseVirtualCard(player, {
        name = "slash", skill_name = skel.name, extra_data = {bypass_distances = true, bypass_times = true},
      })
    end
  end,
})

return skel
